package com.smart.comp;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JTextField;

/**
 *
 * @author zcastle
 */
public class TextoRuc extends JTextField {

    public TextoRuc() {
        this.addKeyListener(new KeyAdapter() {

            @Override
            public void keyTyped(KeyEvent e) {
                char caracter = e.getKeyChar();
                if (TextoRuc.this.getText().length() > 10) {
                    e.consume();
                }
                if (((caracter < KeyEvent.VK_0) || (caracter > KeyEvent.VK_9)) && (caracter != KeyEvent.VK_BACK_SPACE)) {
                    e.consume();
                }
            }
        });

    }
}
